﻿'Created By : Ahmad Abdan
'Date : 09/06/2010
'Subject : Database Table Field Class
Imports System.Data
Public Class TableField

    'fieldName : store the field Name in the DB
    'fieldType : store the field Type in the DB
    'fieldValue : store the fieldValue that will be used later in the Query
    Private FieldName As String
    Private FieldType As SqlDbType
    Private FieldValue As String
    Private FieldSaveEmptyValues As Boolean
    'Initialize Name and Type
    Sub New(ByVal Name As String, ByVal Type As SqlDbType, Optional ByVal SaveEmptyValues As Boolean = False)
        FieldName = Name
        FieldType = Type
        FieldSaveEmptyValues = SaveEmptyValues
        FieldValue = ""
    End Sub
    'Get fieldName To use it when nedded
    Public ReadOnly Property Name() As String
        Get
            Return FieldName
        End Get
    End Property

    'Get fieldType To use it when nedded
    Public ReadOnly Property Type() As SqlDbType
        Get
            Return FieldType
        End Get
    End Property

    'Get fieldValue To use it when nedded
    Public ReadOnly Property Value() As String
        Get
            Return FieldValue
        End Get
    End Property

    Public Sub SetValue(ByVal Value As String, ByRef FieldsArrayList As ArrayList)

        'Choose all and nothing in user control using value -1
        'If (FieldSaveEmptyValues Or Value <> "") And Value <> "-1" Then
        '    FieldValue = Value
        '    FieldsArrayList.Add(Me)
        'End If

        If (FieldSaveEmptyValues Or Value <> "") Then
            FieldValue = Value
            FieldsArrayList.Add(Me)
        End If
    End Sub
End Class